pragma Singleton

import QtQuick 2.0

Item  {
    id: setting

    property string m_language: getOsLanguage()
    property string m_skin: "Default"
    property alias g_Colors: colorInf.item
    property alias g_Language: menuName.item

    property string m_strLoaderPath:""
    property string  m_strPlatfromPath : ""
    property string m_instrumentPanelPath: ""

    Component.onCompleted: {
        //初始化平台信息
        initPlatformInfo()
        //根据不同平台初始化配置信息
        initConfigByPlatform()
    }

    Loader{
        id: menuName
        source: "./Languages/" + m_language + ".qml"
    }

    Loader {
        id: colorInf;
        source: ""
    }

    function getOsLanguage()
    {
        //var m_os = Qt.local().name
        return "Zh_CN"
    }

    function getPlatForm()
    {
        switch (Qt.platform.os)
        {
        case "wince":
        case "linux":
        case "unix":
        case "windows":
        {
            return 1;
        }
        case "blackberry":
        case "winphone":
        case "android":
        case "ios":
        {
            return 2;
        }
        default:
        {
            return 1;
        }
        }
    }

    function initPlatformInfo()
    {
        var nPlatform = getPlatForm()

        switch (nPlatform)
        {
        case 1:
        {
            m_strPlatfromPath = "Win"
            return ;
        }
        case 4:
        {
            m_strPlatfromPath = "Phone"
            return ;
        }
        case 5:
        {
            m_strPlatfromPath = "Pad"
            return ;
        }
        default:
        {
            m_strPlatfromPath = ""
            return ;
        }
        }
    }

    function initConfigByPlatform()
    {
        var nPlatform = getPlatForm()

        switch (nPlatform)
        {
            case 1:
            {
                m_skin = "Default"
                break ;
            }
            case 4:
            case 5:
            {
                m_skin = "DefaultMobile"
                break ;
            }
            default:
            {
                m_skin = "Default"
                break ;
            }
        }

//        colorInf.source = "Style_green.qml";
        colorInf.source = "Style_blue.qml";
        m_strLoaderPath = "./../Config/Skins/"+m_skin+"/Icons/Loader";
        m_instrumentPanelPath = "./../Config/Skins/"+m_skin+"/Icons/headPanel"
    }
}
